<div class="row">
    <div class="col-md-12">
        <div class="box-widget">
            <table id="list-group" class="table data-tbl-boxy responsive">
                <thead>
                    <tr>
                        <th style="width: 5%;">
                            <?php echo $this->translate('STT'); ?>
                        </th>
                        <th>
                            <?php echo $this->translate('title'); ?>
                        </th>
                        <th style="width: 20%;">
                            <?php echo $this->translate('category'); ?>
                        </th>
                        <th style="width: 15%;">
                            <?php echo $this->translate('publish date'); ?>
                        </th>
                        <th style="width: 10%;">
                            <?php echo $this->translate('status'); ?>
                        </th>
                        <th style="width: 10%;">
                            <?php echo $this->translate('tool'); ?>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <?php $i = 0; ?>
                    <?php foreach($this->data as $row): ?>
                    <?php 
                        $i ++; 
                        $url = $this->url(array('module' => 'admin', 'controller' => 'post', 'action' => 'edit', 'id' => $row->id));
                        $deleteUrl = $this->url(array('module' => 'admin', 'controller' => 'post', 'action' => 'delete', 'id' => $row->id));
                        $activeUrl = $this->url(array('module' => 'admin', 'controller' => 'post', 'action' => 'active', 'id' => $row->id));
                        $deactiveUrl = $this->url(array('module' => 'admin', 'controller' => 'post', 'action' => 'deactive', 'id' => $row->id));
                    ?>
                    <tr>
                        <td>
                            <?php echo $i; ?>
                        </td>
                        <td>
                            <a href="<?php echo $url; ?>" title="<?php echo $row->title; ?>">
                                <?php echo $row->title; ?>
                            </a>
                        </td>
                        <td>
                            <?php echo $row->category; ?>
                        </td>
                        <td>
                            <?php echo date("h:i:s d-m-Y", strtotime($row->publish_date)); ?>
                        </td>
                        <td>
                            <?php if($row->status): ?>
                                <a title="<?php echo $this->translate('active'); ?>" href="<?php echo $deactiveUrl; ?>" class="btn btn-mini btn-success">
                                    <i class="icon-ok"></i>
                                </a>
                            <?php else: ?>
                                <a title="<?php echo $this->translate('disable'); ?>" href="<?php echo $activeUrl; ?>" class="btn btn-mini btn-danger">
                                    <i class="icon-remove-6"></i>
                                </a>
                            <?php endif; ?>
                        </td>
                        <td>
                            <a title="<?php echo $this->translate('edit'); ?>" href="<?php echo $url; ?>" class="btn btn-mini btn-primary">
                                <i class="icon-pencil-2"></i>
                            </a>
                            <a onclick="return confirmDelete()" title="<?php echo $this->translate('delete'); ?>" href="<?php echo $deleteUrl; ?>" class="btn btn-mini btn-danger">
                                <i class="icon-remove-2"></i>
                            </a>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script>
function confirmDelete(){
    var ok = confirm('Bạn muốn xóa dòng này?');
    
    if(ok){
        return true;
    }
    
    return false;
}

$(function() {
    $('.data-tbl-boxy').dataTable({
        "sPaginationType": "bootstrap",
        "iDisplayLength": 25,
        "oLanguage": {
            "sLengthMenu": "<span class='lengthLabel pull-left'><?php echo $this->translate('entries_per_page'); ?>:</span><span class='lenghtMenu pull-left'> _MENU_</span>",
            "sInfo": "<?php echo $this->translate('show start end records of total'); ?>",
            "sSearch": "<?php echo $this->translate('filter'); ?>:",
            "oPaginate": {
                "sFirst": "<?php echo $this->translate('first page'); ?>",
                "sLast": "<?php echo $this->translate('last page'); ?>",
                "sNext": "<?php echo $this->translate('next page'); ?>",
                "sPrevious": "<?php echo $this->translate('previous page'); ?>"
            }
        },
        "sDom": '<"widget-head clearfix"fl>,<"widget-container"<"widget-block"<"widget-content"t>,,<"table-bottom clearfix"<"tbl-pagination pull-left"p><"tbl-data-info pull-right"i>>'
    });
});
</script>